﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NoKeyGenerator.Model;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

namespace NoKeyGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            // Loading domain configuration section with name "Default".
            var domainConfiguration = DomainConfiguration.Load("Default");
            var domain = Domain.Build(domainConfiguration);

            using (var session = domain.OpenSession()) {
                using (var t = session.OpenTransaction()) {

                    // As Book hierarchy is not served with any key generator (see Book.cs for KeyGenerator attribute)
                    // we have to always provider the value for Id field, so we use Isbn here.
                    var book = new Book(session, "978-1617291340") {
                        Title = "C# in Depth",
                        Author = "Jon Skeet"
                    };

                    Console.WriteLine(book.Key);
                    t.Complete();
                }
            }
        }
    }
}
